package com.sxz.sbs.module.sale.presenter;

import com.sxz.sbs.app.App;
import com.sxz.sbs.module.sale.mode.StallListBean;
import com.sxz.sbs.module.sale.view.SaleControlStallView;
import com.sxz.sbs.rx.RxPresenter;
import com.sxz.sbs.rx.RxSubscriber;
import com.sxz.sbs.rx.RxUtil;

import java.util.HashMap;

/**
 * Created by Administrator on 2018/1/16 0016.
 */

public class SaleControlStallPresenter extends RxPresenter<SaleControlStallView>{
    /**
     * 车位销控车位列表
     * @param map
     */
    public void getStallList (HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().getParkingStall(map)
                .compose(RxUtil.<StallListBean>handleResult())
                .subscribeWith(new RxSubscriber<StallListBean>(mView){
                    @Override
                    public void onNext(StallListBean data) {
                        mView.onGetStallListSuccess(data);
                    }
                })
        );
    }
    /**
     * 添加意向
     * @param map
     */
    public void addIntentStall (HashMap<String,Object> map) {
        addSubscribe(App.getInstance().getApi().addIntentStall(map)
                .compose(RxUtil.<String>handleResult())
                .subscribeWith(new RxSubscriber<String>(mView){
                    @Override
                    public void onNext(String data) {
                        mView.onAddIntentStallSuccess();
                    }
                })
        );
    }
}
